<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<%@ include file="/common/mainhead.html" %>
<script>
	var frameStr = "window.frames['toTest']";

	function test(){
		$.post("getTestValue.do", function(data){
			$('#lab_test').html(data);
		});		
	}
	
	//-----------------------------------------------导入
	//打开导入窗口
	function showImportWin(){
		var dialogId = 'myDialogId';
    	var title = '导入';
    	var content = $('#win_upload_content').html().replaceAll('uploadHandle',frameStr + '.uploadExcel()');;
    	openFrameDialog(dialogId, title, 390, 160, content, '');
	}
	
	//执行导入
	function uploadExcel(){
		var filePath = top$('#file_localFile').val();
		if(filePath == ""){
			top$.showWarnMessage("请选择上传文件");
		    return;
		}
	    var strTemp = filePath.split("."); 
	    var temp = strTemp[strTemp.length-1].toLowerCase();
	    if(temp != "xls" && temp != "xlsx"){
	    	top$.showWarnMessage("请上传xls或xlsx格式文件");
	    	return;
	    }
	    top$('#butt_upload').attr('disabled',true);	    
	    top$('#form_uploadfile').submit();
	    top$.messager.progress({
	    	title:'上传文件',
	    	msg:'正在上传...'
	    });
	    
	    var serverNewFileName = top$('#hide_serverNewFileName').val();
	    timeid = window.setInterval(function(){
	    	serverNewFileName = top$('#hide_serverNewFileName').val();
	    	if(serverNewFileName != ''){
	    			clearInterval(timeid);
	    			top$.messager.progress('close');
	    			top$('#myDialogId').dialog('close');
	    			window.location.href='toUploadExcelDataShow.do?newFileName='+serverNewFileName+'&targetPath=test/uploadTestDataShow';
	    	}
	    },1000);
	}
	
	//-----------------------------------------------导出
	function exportData(){
		$('#exportForm').submit();
	}
	
</script>
</head>
<body>
	<div>
		<label id="lab_test">#</label>
		<input id="butt_test" onclick="test();" type="button" value="测试"/>
		<input id="butt_test" onclick="showImportWin();" type="button" value="导入"/>
		<input id="butt_test" onclick="exportData();" type="button" value="导出"/>
	</div>
   	<div id="win_upload_content" style="display:none;">
		<form id="form_uploadfile" style="margin:5px;" action="templateFileUpload.do" method="post" enctype="multipart/form-data" target="hidden_frame">
			<input type="hidden" id="hide_serverNewFileName"/>
			<table style="text-align:center;">
				<tr>
					<td width="100px" height="70px">文件:</td>
					<td>
						<input name="file_localFile" id="file_localFile" type="file" style="width: 300px;" />
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<a id="butt_upload" href="#" class="easyui-linkbutton" onclick="uploadHandle" style="width: 300px;">上传</a>
					</td>
				</tr>
			</table>
			<iframe id="hidden_frame" name="hidden_frame" frameborder="0" border="0" style="display:none;width:0px;height:0px;">     
    		</iframe>				
		</form>
   	</div>
   	<form action="exportTestInfo.do" id="exportForm">
   	</form>
</body>
</html>